/* GUI CONVERTED from rqpoiq.p (converter v1.75) Sat Aug 12 23:12:51 2000 */
/* rqpoiq.p -  PURCHASE ORDER vs REQUISITION NBR                            */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/*K1P0*/
/*V8:ConvertMode=Report                                                     */
/* REVISION 8.5             CREATED: 06/13/97  BY: *J1Q2* Vinay Nayak-Sujir */


/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 04/30/98   BY: *K1P0* A. Shobha */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Brian Compton    */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                */

         /* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

         {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rqpoiq_p_1 "Req Nbr"
/* MaxLen: Comment: */

&SCOPED-DEFINE rqpoiq_p_2 "Req"
/* MaxLen: Comment: */

&SCOPED-DEFINE rqpoiq_p_3 "Description"
/* MaxLen: Comment: */

&SCOPED-DEFINE rqpoiq_p_4 "Order"
/* MaxLen: Comment: */

&SCOPED-DEFINE rqpoiq_p_5 "PO Nbr"
/* MaxLen: Comment: */

&SCOPED-DEFINE rqpoiq_p_6 "Ln"
/* MaxLen: Comment: */

&SCOPED-DEFINE rqpoiq_p_7 "Sub-Acct"
/* MaxLen: Comment: */

&SCOPED-DEFINE rqpoiq_p_8 "CC"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */


         define variable ext_cost       like pod_pur_cost no-undo.
         define variable descr          as character format "X(13)" no-undo.

         define variable reqnbr         like req_nbr no-undo.
         define variable ponbr          like po_nbr no-undo.
         define variable po_inquiry     like mfc_logical no-undo.

         /* Selection frame */
         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
space(4)
            ponbr              label {&rqpoiq_p_5}
        space(4)
            reqnbr             label {&rqpoiq_p_1}
         with frame a attr-space side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         /* PO Inquiry frame */
         FORM /*GUI*/ 
            rqpo_po_line        label {&rqpoiq_p_6}
            rqpo_req_nbr        label {&rqpoiq_p_2}
            rqpo_req_line       label {&rqpoiq_p_6}
            descr               label {&rqpoiq_p_3}
            pod_acct
/*N014*/    pod_sub             label {&rqpoiq_p_7}
/*N014*     pod_cc              label "CC" */
/*N014*/    pod_cc              label {&rqpoiq_p_8}
/*N014*     ext_cost */
/*N014*/    ext_cost            at 58
/*N014*     pod_qty_ord */
/*N014*/    pod_qty_ord         at 60
         with STREAM-IO /*GUI*/  frame poframe down width 80.

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame poframe:handle).

         /* REQ Inquiry frame */
         FORM /*GUI*/ 
            rqpo_req_line       label {&rqpoiq_p_6}
            rqpo_po_nbr         label {&rqpoiq_p_4}
            rqpo_po_line        label {&rqpoiq_p_6}
            descr               label {&rqpoiq_p_3}
            pod_acct
/*N014*/    pod_sub             label {&rqpoiq_p_7}
/*N014*     pod_cc              label "CC" */
/*N014*/    pod_cc              label {&rqpoiq_p_8}
/*N014*     ext_cost */
/*N014*/    ext_cost            at 58
/*N014*     pod_qty_ord */
/*N014*/    pod_qty_ord         at 60
         with STREAM-IO /*GUI*/  frame reqframe down width 80.

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame reqframe:handle).

         ststatus = stline[1].
         status input ststatus.

/*K1P0*/ {wbrp01.i}

         repeat:

/*K1P0*/ if c-application-mode <> 'WEB':U then
              update ponbr with frame a editing:
                  /* FIND NEXT/PREVIOUS RECORD */
                  {mfnp.i rqpo_ref ponbr rqpo_po_nbr
                                   ponbr rqpo_po_nbr rqpo_po_nbr}

                  if recno <> ? then do:
                       display rqpo_po_nbr @ ponbr
                       with frame a.
                  end.
              end.  /* prompt-for ponbr */



/*K1P0*/ if c-application-mode <> 'WEB':U then
              update reqnbr with frame a editing:
                  /* FIND NEXT/PREVIOUS RECORD  */
                  {mfnp.i rqpo_ref reqnbr rqpo_req_nbr
                                   reqnbr rqpo_req_nbr rqpo_req_nbr}

                  if recno <> ? then do:
                      display rqpo_req_nbr @ reqnbr
                      with frame a.
                  end.
              end.

/*K1P0*/ {wbrp06.i &command = update &fields = "ponbr reqnbr"  &frm = "a"}

              hide frame poframe.
              clear frame poframe all.

              hide frame reqframe.
              clear frame reqframe all.

              /* SELECT PRINTER */
              {mfselprt.i "terminal" 80}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.


              /* If only PO# has been specified then sort by PO# and
                 display all crossref records from that PO onwards

                 If only Req# has been specified then sort by Req# and
                 display all crossref records from that Req# onwards

                 If both have been specified then sort by PO# and
                 display all crossref records from that PO# and Req# onwards */

              if ponbr <> "" then do:
                 po_inquiry = yes.
                 for each rqpo_ref where
                     rqpo_po_nbr = ponbr no-lock,
                     each rqd_det where
                          rqd_nbr = rqpo_req_nbr and
                          rqd_line = rqpo_req_line no-lock,
                     each pod_det where
                          pod_nbr = rqpo_po_nbr and
                          pod_line = rqpo_po_line no-lock
                     by rqpo_po_nbr by rqpo_po_line:

                     /* If both PO # and Requistion# have been specified,
                        then start at that PO# and Req# */
                     if reqnbr <> "" and
                        rqpo_req_nbr < reqnbr then
                        next.

                     if pod_desc <> "" and
                        pod_desc <> "Item not in inventory"  then
                        descr = pod_desc.
                     else
                        descr = pod_part.


                     display
                        rqpo_po_line
                        rqpo_req_nbr
                        rqpo_req_line
                        descr
                        pod_acct
/*N014*/                pod_sub
                        pod_cc
                        (pod_pur_cost * pod_qty_ord *
                           ( 1 - pod_disc_pct / 100 )) @ ext_cost
                        pod_qty_ord
                        with frame poframe STREAM-IO /*GUI*/ .
                     down 1
                        with frame poframe.

                 end. /* for each rqpo_ref */
              end.  /* if ponbr <> "" */
              else do:
                 po_inquiry = no.
                 for each rqpo_ref where
                     rqpo_req_nbr = reqnbr no-lock,
                     each rqd_det where
                          rqd_nbr = rqpo_req_nbr and
                          rqd_line = rqpo_req_line no-lock,
                     each pod_det where
                          pod_nbr = rqpo_po_nbr and
                          pod_line = rqpo_po_line no-lock
                     by rqpo_po_nbr by rqpo_po_line:

                     if pod_desc <> "" and
                        pod_desc <> "Item not in inventory"  then
                        descr = pod_desc.
                     else
                        descr = pod_part.


                     display
                        rqpo_req_line
                        rqpo_po_nbr
                        rqpo_po_line
                        descr
                        pod_acct
/*N014*/                pod_sub
                        pod_cc
                        (pod_pur_cost * pod_qty_ord *
                            ( 1 - pod_disc_pct / 100 )) @ ext_cost
                        pod_qty_ord
                        with frame reqframe STREAM-IO /*GUI*/ .
                     down 1
                        with frame reqframe.

                 end. /* for each rqpo_ref */
              end.  /* else do for rqnbr  */
/*K1P0*/      {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


         end.   /* repeat  */

         status input.

/*K1P0*/ {wbrp04.i &frame-spec = a}
